package com.liuhm.controller;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author liuhaomin
 * @date 2020/10/28
 */
public class FixedThreadPool {
    static class MyThread extends Thread{
        private String name;
        public MyThread(String name)
        {
            this.name = name;
        }

        @Override
        public void run() {
            System.err.println(Thread.currentThread().getName());
            System.err.println(name);
            try {
                Thread.sleep(6000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    public static void main(String[] args) {
        ExecutorService exec = Executors.newFixedThreadPool(5);
        for(int i = 1;i<=20;i++) {
            exec.submit(new MyThread(String.valueOf(i)));
        }
        exec.shutdown();
    }
}
